<!-- eslint-disable vue/multi-word-component-names -->
<template>
  <div class="father">
    <el-page-header @back="goBack" content="购买页面" class="header"></el-page-header>
    <div class="body">
      <div>
        <div class="body-item1">
          <el-image style="width: 450px" :src="url" :preview-src-list="srcList">
          </el-image>
        </div>
        <div class="body-item2">
          <div class="item2-item1">
            <div class="item1-content1">
              <h3>问界 M5 行无界 智千里</h3>
            </div>
            <div class="item1-content2">
              <div>销售价：￥279,800</div>
              <div>
                <p> 销售数量
                  <button @click="num == 0 ? 0 : num --">-</button>
                  <button>{{ num }}</button>
                  <button @click="num++">+</button>
                </p>
              </div>
              <div class="money">所需金额：￥{{ total }}</div>
              <div class="content2-item3"><button class="item3-button" @click="pay">立即购买</button><button class="item3-button"
                  @click="addShopcart">加入购物车</button></div>
            </div>
          </div>
          <div class="item2-item2">
            <div class="item2-content1">
              <h3>商品参数</h3>
            </div>
            <div class="item2-content2">
              <p>车辆配置：后驱智驾版/冰晶灰/极夜黑/20英寸十辐铝制轮毂/无科技舒享包</p>
              <p>享受服务：赠送至高42000元权益（限2023年12月1日-2023年12月31日下定用户），如有疑问建议您咨询门店顾问。</p>
              <p>CLTC综合续航里程：1425公里</p>
              <p>CLTC纯电续航里程：255公里</p>
              <p>四驱百公里加速：4.4秒</p>
              <p>后驱百公里加速：7.1秒</p>
              <p>对外放电：3.5千瓦</p>
              <p>仿生灵感：智慧眼激光雷达/智慧眼侧面摄像头/流光聚能醒狮大灯/流体动感车身/鹰翼贯穿式尾灯/20英寸双五辐运动轮毂</p>
              <p>车身颜色：松霜绿/天青蓝/陶瓷白/鎏金黑/暖星云/冰晶灰</p>
              <p>精美座舱：韶华杏/雀羽红/琥珀棕/极夜黑</p>
              <p>科技豪华：车载超级快充/HUAWEI SOUND 空间音频/后视镜自动调节/HUD高度智能调节/小憩模式</p>
              <p>主动安全辅助：自动紧急制动（AEB）/异形障碍物自动紧急制动（GAEB）</p>
              <p>澎湃动力：HUAWEI DriveONE/HUAWEI DATS/百万豪车全铝底盘/图书馆级静谧舒适空间</p>
              <p>鸿蒙座舱：超级桌面/PC协同/查车位及跨楼层车位导航/碰一碰轻松导航/座舱K歌房/沉浸式游戏</p>
              <p>0-100km/h加速时间：4.4秒</p>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="hello_world">
      <button class="top" @click="toTop">
        <img src="@/assets/backToTop.png" width="100%">
      </button>
    </div>
  </div>
</template>

<script>
  import BScroll from 'better-scroll'
  export default {
    name: 'z_seven_shop',
    data() {
      return {
        num: 0,
        url: 'https://res.vmallres.com//uomcdn/CN/pms/202311/D361656B9AF3F0EBFCD71A8475BEBFD2.jpg',
        srcList: [
          'https://res.vmallres.com//uomcdn/CN/pms/202311/D361656B9AF3F0EBFCD71A8475BEBFD2.jpg'
        ]
      }
    },
    methods: {
      goBack() {
        this.$router.go(-1)
      },
      toTop() {
        window.location.reload()
      },
      sunAdd() {
        this.num = this.num + 1
      },
      sumDelete() {
        if (this.num === 0) {
          this.num = this.num - 0
        } else {
          this.num = this.num - 1
        }
      },
      addShopcart() {
        this.$store.commit('shopcart/addShopcart', {
          id: 4,
          count: parseInt(this.num),
          url: 'https://res.vmallres.com//uomcdn/CN/pms/202311/D361656B9AF3F0EBFCD71A8475BEBFD2.jpg',
          price: 279800,
          detail: '问界 M5',
          selected: true,
          path: '/w_five/shop'
        })
      },
      pay() {
        this.$router.push({
          name: 'pay',
          params: {
            detail: {
              id: 4,
              count: parseInt(this.num),
              url: 'https://res.vmallres.com//uomcdn/CN/pms/202311/D361656B9AF3F0EBFCD71A8475BEBFD2.jpg',
              price: 279800,
              detail: '问界 M5',
              selected: true,
              path: '/w_five/shop'
            }
          }
        })
        this.$store.state.onHomePage = false
      }
    },
    computed: {
      total() {
        return this.num * 279800
      }
    },
    mounted() {
      this.$nextTick(() => {
        // eslint-disable-next-line no-undef
        this.scroll = new BScroll('.body', {
          click: true,
          mouseWheel: true
        })
      })
    }
  }
</script>

<style scoped>
  .money {
    margin-bottom: 10px;
  }

  .item3-button {
    background-color: red;
    border-radius: 5px;
    margin: 3px;
    opacity: 0.8;
  }

  .item1-content2 {
    margin-top: 10px;
    margin-bottom: 10px;
  }

  .item2-content2 {
    margin-top: 10px;
    margin-bottom: 10px;
  }

  .item1-content1 {
    border-bottom: solid 1px gray;
  }

  .item2-content1 {
    border-bottom: solid 1px gray;
  }

  .item2-item2 {
    width: 440px;
    margin: 2px;
    border: solid 1px gray;
    border-radius: 5px;
    background-color: #fff;
    padding-left: 5px;
  }

  .item2-item1 {
    width: 440px;
    margin: 2px;
    border: solid 1px gray;
    border-radius: 5px;
    background-color: #fff;
    padding-left: 5px;
  }

  .top {
    position: absolute;
    width: 40px;
    height: 40px;
    bottom: 100px;
    right: 5px;
    background-color: #fff;
    border: solid 1px gray;
    border-radius: 50%;
  }

  .body-item1 {
    width: 450px;
    height: 50%;
  }

  .father {
    width: 450px;
    height: 100%;
  }

  .header {
    width: 100%;
    height: 5%;
  }

  .body {
    width: 450px;
    height: 630px;
    overflow: hidden;
    background-color: #888;
    border-bottom: solid 1px gray;
  }
</style>
